package com.edu.app.service.impl.linkservices;

import com.edu.app.bean.core.SysActivity;
import com.edu.app.bean.core.SysUser;
import com.edu.app.bean.linkbeans.SysUserActivity;
import com.edu.app.bean.virtualbean.UserActByDate;

import com.edu.app.bean.virtualbean.UserActWx;
import com.edu.app.mapper.linkmappers.SysUserActivityMapper;
import com.edu.app.service.impl.SysBaseServiceImpl;
import com.edu.app.service.sys.linkservices.SysUserActivityService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SysUserActivityServiceImpl extends SysBaseServiceImpl<SysUserActivity,SysUserActivityMapper> implements SysUserActivityService {

    @Autowired
    private SysUserActivityMapper sysUserActivityMapper;



    @Override
    public PageInfo getInComingActivityModel(String username, String role, Integer currentPage, Integer pageSize, String type){
        PageHelper.startPage(currentPage, pageSize, true);

        List<UserActByDate> list = sysUserActivityMapper.getInComingActivityModel(username, role, type);

        PageInfo<UserActByDate> pageInfo = new PageInfo<UserActByDate>(list);
        return pageInfo;
    }

    @Override
    public PageInfo getActivityModelByStatus(String username, Integer status, String role, String type, Integer currentPage, Integer pageSize, String seq){
        PageHelper.startPage(currentPage, pageSize, true);

        List<UserActByDate> list = sysUserActivityMapper.getActivityModelByStatus(username, status, role, type, seq);

        PageInfo<UserActByDate> pageInfo = new PageInfo<UserActByDate>(list);
        return pageInfo;
    }

    @Override
    public PageInfo getUserPendingActivityByPage(String username, Integer currentPage, Integer pageSize) {
        //设置分页信息，分别是当前页数和每页显示的总记录数【记住：必须在mapper接口中的方法执行之前设置该分页信息】
        PageHelper.startPage(currentPage, pageSize, true);
        List<SysActivity> list = sysUserActivityMapper.getUserPendingActivityByPage(username);

        PageInfo<SysActivity> pageInfo = new PageInfo<SysActivity>(list);
        return pageInfo;
    }

    @Override
    public PageInfo getUserCompletedActivityByPage(String username, Integer currentPage, Integer pageSize) {
        //设置分页信息，分别是当前页数和每页显示的总记录数【记住：必须在mapper接口中的方法执行之前设置该分页信息】
        PageHelper.startPage(currentPage, pageSize, true);
        List<SysActivity> list = sysUserActivityMapper.getUserCompletedActivityByPage(username);

        PageInfo<SysActivity> pageInfo = new PageInfo<SysActivity>(list);
        return pageInfo;
    }

    @Override
    public PageInfo getMyPendingFeedbackActivity(String username, Integer currentPage, Integer pageSize) {
        //设置分页信息，分别是当前页数和每页显示的总记录数【记住：必须在mapper接口中的方法执行之前设置该分页信息】
        PageHelper.startPage(currentPage, pageSize, true);
        List<SysActivity> list = sysUserActivityMapper.getUserPendingFeedbackByPage(username);

        PageInfo<SysActivity> pageInfo = new PageInfo<SysActivity>(list);
        return pageInfo;
    }

    @Override
    public PageInfo getUserActivityByPage(String username, Integer currentPage, Integer pageSize) {
        //设置分页信息，分别是当前页数和每页显示的总记录数【记住：必须在mapper接口中的方法执行之前设置该分页信息】
        PageHelper.startPage(currentPage, pageSize, true);
        List<SysActivity> list = sysUserActivityMapper.getUserActivityByPage(username);

        PageInfo<SysActivity> pageInfo = new PageInfo<SysActivity>(list);
        return pageInfo;
    }

    @Override
    public List<SysActivity> getActivityByUserId(Integer id){

        List<SysActivity> sysActivityList = sysUserActivityMapper.getActivityByUserId(id);
        return sysActivityList;
    }

    @Override
    public List<SysActivity> getActivityByUserName(String user_name, String date){

        //format the date to usable for sql search
        //SimpleDateFormat dateFormat= new SimpleDateFormat("yyyy-MM-dd");
        //String date = dateFormat.format(day);
        List<SysActivity> sysActivityList = sysUserActivityMapper.getActivityByUserName(user_name, date);
        return sysActivityList;
    }

    @Override
    public List<SysUser> getUserByActivityId(Integer id){

        List<SysUser> sysUserList = sysUserActivityMapper.getUserByActivityId(id);
        return sysUserList;
    }

    @Override
    public List<String> getDateHasActivity(String username, String rolePlay){
        List<String> dateHasActivity = sysUserActivityMapper.getDateHasActivity(username, rolePlay);
        return dateHasActivity;
    }

    @Override
    public SysUserActivity getUserActivity(Integer user_id, Integer activity_id){
        return sysUserActivityMapper.getUserActivity(user_id, activity_id);
    }

    @Override
    public Integer deleteUserActivityByActivityId(Integer activity_id){
        return sysUserActivityMapper.deleteUserActivityByActivityId(activity_id);
    }

    @Override
    public Integer deleteUserActivityByUserId(Integer user_id){
        return sysUserActivityMapper.deleteUserActivityByUserId(user_id);
    }

    @Override
    public Integer getUserPendingActivityNumber(String username, String type, String rolePlay){
        return sysUserActivityMapper.getUserPendingActivityNumber(username, type, rolePlay);
    }

    @Override
    public List<UserActWx> getUserActWx(){
        return sysUserActivityMapper.getUserActWx();
    }
}
